package com.atguigu.serviceedu.controller;


import com.atguigu.commonutils.R;
import com.atguigu.serviceedu.entity.vo.SubjectNestedVo;
import com.atguigu.serviceedu.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author Return
 * @since 2021-03-10
 */
@Api(description = "课程管理")
@RestController
@RequestMapping("/eduservice/edu-subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //添加课程文件
    //获取上传过来的文件，把文件内容读取出来
    @ApiOperation(value = "Excel批量导入")
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){

        subjectService.saveSubject(file, subjectService);

        return R.ok();
    }

    @ApiOperation(value = "嵌套数据列表")
    @GetMapping("nestList")
    public R nestList(){

        List<SubjectNestedVo> subjectNestedVos = subjectService.nestedList();
        return R.ok().data("items",subjectNestedVos);
    }

}

